/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package org.jackysoft.opensymphony.workflow.entity;



/**
 * 
 */


public class PermissionDescriptor extends AbstractDescriptor {
    //~ Instance fields ////////////////////////////////////////////////////////

    /**
	 * 
	 */
	private static final long serialVersionUID = -4200745318368811420L;
	protected RestrictionDescriptor restriction;
    protected String name;

    //~ Constructors ///////////////////////////////////////////////////////////

    /**
     * 
     */
   public PermissionDescriptor() {
    }

   public PermissionDescriptor(org.dom4j.Element element) {
	   super(element);this.init(element);
    }

    //~ Methods ////////////////////////////////////////////////////////////////

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setRestriction(RestrictionDescriptor restriction) {
        this.restriction = restriction;
    }

    
    
    public RestrictionDescriptor getRestriction() {
        return restriction;
    }

  
    @Override
    protected void init(org.dom4j.Element permission) {
    	name = permission.attributeValue("name");
    	
    	try {
    		setId(Integer.parseInt(permission.attributeValue("id")));
    	} catch (NumberFormatException e) {
    	}
    	
    	restriction = new RestrictionDescriptor(permission.element("restrict-to"));
    	//XmlUtils.getChildElement(permission, "restrict-to"));
    }
}
